from langchain_openai import ChatOpenAI
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from openaiConfigurations import openai_api_key, openai_api_base
# 标准输出回调将生成的内容打印到控制台
llm = ChatOpenAI(streaming = True, 
                 callbacks = [StreamingStdOutCallbackHandler()],
                 temperature = 0,
                 openai_api_key = openai_api_key,
                 openai_api_base = openai_api_base)
# resp = llm.invoke("write me a song about sparking water")
# print(resp.content)

# 返回一个LLMResult结果
print(llm.generate(["tell me a joke."]))